package cn.janus.controller;

import cn.janus.pojo.param.BillRecordParam;
import cn.janus.pojo.vo.BillForMonthVO;
import cn.janus.pojo.vo.BillTripVO;
import cn.janus.response.JsonResult;
import cn.janus.service.IBillService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("wolf/tally/")
public class TallyController {
    private final IBillService service;

    public TallyController(IBillService bill) {
        this.service = bill;
    }

    /**
     * 添加新的收支情况
     */
    @PostMapping("record")
    public JsonResult Record(@RequestBody List<BillRecordParam> params) {
        service.record(params);
        return JsonResult.ok();
    }

    /**
     * 查询最新的8条收支记录
     */
    @GetMapping("bill_detail")
    public JsonResult billDetail() {
        return JsonResult.ok(service.billDetail());
    }

    /**
     * 统计指定月份的收支情况
     *
     * @param date 月份
     */
    @GetMapping("month")
    public JsonResult billForMonth(String date) {
        BillForMonthVO list = service.billForMonthService(date);
        return JsonResult.ok(list);
    }

    /**
     * 统计旅途花费
     */
    @GetMapping("trip")
    public JsonResult billTrip() {
        List<BillTripVO> list = service.billTripService();
        return JsonResult.ok(list);
    }


}
